import type { RouteRecordRaw } from 'vue-router';
import { BasicLayout } from '#/layouts';
import { $t } from '#/locales';
import {
  DoorClosed,
  LogIn,
  Truck,
  Users,
  ShieldAlert,
  Warehouse,
} from 'lucide-vue-next';

const routes: RouteRecordRaw[] = [
  {
    component: BasicLayout,
    meta: {
      icon: DoorClosed,
      order: 1000,
      title: $t('page.closedManagement.title'),
    },
    name: 'ClosedManagement',
    path: '/closed-management',
    children: [
      // {
      //   name: 'ClosedManagementHome',
      //   path: 'home',
      //   component: () => import('#/views/closed-management/Home.vue'),
      //   meta: {
      //     icon: Home,
      //     title: $t('page.closedManagement.home'),
      //   },
      // },
      {
        name: 'AccessControl',
        path: 'access-control',
        meta: {
          icon: ShieldAlert,
          title: $t('page.closedManagement.accessControl'),
          authority: ['AC100000', 'AC100001'],
        },
        children: [
          // {
          //   name: 'DataAnalysis',
          //   path: 'data-analysis',
          //   component: () => import('#/views/closed-management/access-control/DataAnalysis.vue'),
          //   meta: {
          //     icon: BarChart3,
          //     title: $t('page.closedManagement.dataAnalysis'),
          //   },
          // },
          {
            name: 'PersonnelPassageRecord',
            path: 'personnel-passage',
            component: () =>
              import(
                '#/views/closed-management/access-control/PersonnelPassageRecord.vue'
              ),
            meta: {
              // icon: UserCheck,
              title: $t('page.closedManagement.personnelPassageRecord'),
              username: '人员通行记录',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'VehiclePassageRecord',
            path: 'vehicle-passage',
            component: () =>
              import(
                '#/views/closed-management/access-control/VehiclePassageRecord.vue'
              ),
            meta: {
              // icon: Car,
              title: $t('page.closedManagement.vehiclePassageRecord'),
              username: '车辆通行记录',
              authority: ['AC100000', 'AC100001'],
            },
          },
          // {
          //   name: 'ItemPassageRecord',
          //   path: 'item-passage',
          //   component: () =>
          //     import(
          //       '#/views/closed-management/access-control/ItemPassageRecord.vue'
          //     ),
          //   meta: {
          //     // icon: Briefcase,
          //     title: $t('page.closedManagement.itemPassageRecord'),
          //     username: '物品通行记录',
          //   },
          // },
          {
            name: 'AutoReleaseManagement',
            path: 'auto-release',
            component: () =>
              import(
                '#/views/closed-management/access-control/AutoReleaseManagement.vue'
              ),
            meta: {
              // icon: Cog,
              title: $t('page.closedManagement.autoReleaseManagement'),
              username: '自动放行管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'LocationDeviceRegistration',
            path: 'location-device',
            component: () =>
              import(
                '#/views/closed-management/access-control/LocationDeviceRegistration.vue'
              ),
            meta: {
              // icon: MapPin,
              title: $t('page.closedManagement.locationDeviceRegistration'),
              username: '定位设备登记',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'AccessControlInfo',
            path: 'info',
            component: () =>
              import(
                '#/views/closed-management/access-control/AccessControlInfo.vue'
              ),
            meta: {
              // icon: FileText,
              title: $t('page.closedManagement.accessControlInfo'),
              username: '门禁卡口信息',
              authority: ['AC100000', 'AC100001'],
            },
          },

          {
            name: 'DeviceInforment',
            path: 'device-informent',
            component: () =>
              import(
                '#/views/closed-management/access-control/DeviceInforment.vue'
              ),
            meta: {
              // icon: FileText,
              title: $t('page.closedManagement.deviceInforment'),
              username: '',
              authority: ['AC100000', 'AC100001'],
            },
          },
          
        ],
      },
      {
        name: 'EntryExit',
        path: 'entry-exit',
        meta: {
          icon: LogIn,
          title: $t('page.closedManagement.entryExit'),
          authority: ['AC100000', 'AC100001', 'AC999999', 'AC100010'],
        },
        children: [
          {
            name: 'PersonnelEntryExitApplication',
            path: 'personnel-application',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/PersonnelEntryExitApplication.vue'
              ),
            meta: {
              // icon: Users,
              title: $t('page.closedManagement.personnelEntryExitApplication'),
              username: '人员出入园管理-申请',
              authority: ['AC100000', 'AC100001', 'AC999999'],
            },
          },
          {
            name: 'PersonnelEntryExitReview',
            path: 'personnel-review',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/PersonnelEntryExitReview.vue'
              ),
            meta: {
              // icon: ClipboardList,
              title: $t('page.closedManagement.personnelEntryExitReview'),
              username: '人员出入园管理-审核',
              authority: ['AC100000', 'AC100001', 'AC100010'],
            },
          },
          {
            name: 'VehicleEntryExitApplication',
            path: 'vehicle-application',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/VehicleEntryExitApplication.vue'
              ),
            meta: {
              // icon: Car,
              title: $t('page.closedManagement.vehicleEntryExitApplication'),
              username: '车辆出入申请',
              authority: ['AC100000', 'AC100001', 'AC999999'],
            },
          },
          {
            name: 'VehicleEntryExitReview',
            path: 'vehicle-review',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/VehicleEntryExitReview.vue'
              ),
            meta: {
              // icon: ClipboardCheck,
              title: $t('page.closedManagement.vehicleEntryExitReview'),
              username: '车辆出入审核',
              authority: ['AC100000', 'AC100001', 'AC100010'],
            },
          },
          {
            name: 'HazardousVehicleReservation',
            path: 'hazardous-vehicle',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/HazardousVehicleReservation.vue'
              ),
            meta: {
              // icon: Truck,
              title: $t('page.closedManagement.hazardousVehicleReservation'),
              username: '危化品车辆预约管理',
              authority: ['AC100000', 'AC100001', 'AC999999'],
            },
          },
          {
            name: 'HazardousVehicleReview',
            path: 'hazardous-vehicle-review',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/HazardousVehicleReview.vue'
              ),
            meta: {
              // icon: ClipboardCheck,
              title: $t('page.closedManagement.hazardousVehicleReview'),
              username: '危险品车辆预约审核',
              authority: ['AC100000', 'AC100001', 'AC100010'],
            },
          },
          {
            name: 'BlacklistManagement',
            path: 'blacklist',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/BlacklistManagement.vue'
              ),
            meta: {
              // icon: UserX,
              title: $t('page.closedManagement.blacklistManagement'),
              username: '黑名单管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'AbnormalBehaviorAlarm',
            path: 'abnormal-behavior',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/AbnormalBehaviorAlarm.vue'
              ),
            meta: {
              // icon: AlertTriangle,
              title: $t('page.closedManagement.abnormalBehaviorAlarm'),
              username: '异常行为报警管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'AlarmData',
            path: 'alarm-data',
            component: () =>
              import('#/views/closed-management/entry-exit/AlarmData.vue'),
            meta: {
              // icon: Bell,
              title: $t('page.closedManagement.alarmData'),
              username: '报警数据',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'ZoneAuthorization',
            path: 'zone-authorization',
            component: () =>
              import(
                '#/views/closed-management/entry-exit/ZoneAuthorization.vue'
              ),
            meta: {
              // icon: MapPin,
              title: $t('page.closedManagement.zoneAuthorization'),
              username: '区域授权管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
        ],
      },
      {
        name: 'HazardousTransport',
        path: 'hazardous-transport',
        meta: {
          icon: Truck,
          title: $t('page.closedManagement.hazardousTransport'),
          authority: ['AC100000', 'AC100001'],
        },
        children: [
          {
            name: 'UnsafeDrivingAlarm',
            path: 'unsafe-driving-alarm',
            component: () =>
              import(
                '#/views/closed-management/hazardous-transport/UnsafeDrivingAlarm.vue'
              ),
            meta: {
              // icon: AlertCircle,
              title: $t('page.closedManagement.unsafeDrivingAlarm'),
              username: '不安全驾驶行为报警',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'ElectWayment',
            path: 'elect-wayment',
            component: () =>
              import(
                '#/views/closed-management/hazardous-transport/ElectWayment.vue'
              ),
            meta: {
              // icon: AlertCircle,
              title: $t('page.closedManagement.electWayment'),
              username: '电子运单管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'HazardousChemicalsManagement',
            path: 'chemicals-management',
            component: () =>
              import(
                '#/views/closed-management/hazardous-transport/HazardousChemicalsManagement.vue'
              ),
            meta: {
              // icon: Beaker,
              title: $t('page.closedManagement.hazardousChemicalsManagement'),
              username: '危化品管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'HazardousVehicleTracking',
            path: 'vehicle-tracking',
            component: () =>
              import(
                '#/views/closed-management/hazardous-transport/HazardousVehicleTracking.vue'
              ),
            meta: {
              // icon: Crosshair,
              title: $t('page.closedManagement.hazardousVehicleTracking'),
              username: '危化品车辆跟踪',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'TransportationVehicles',
            path: 'transportation-vehicles',
            component: () =>
              import(
                '#/views/closed-management/hazardous-transport/TransportationVehicles.vue'
              ),
            meta: {
              // icon: AlertCircle,
              title: $t('page.closedManagement.transportationvehicles'),
              username: '运输车辆统计分析',
              authority: ['AC100000', 'AC100001'],
            },
          },
          // {
          //   name: 'RoutePlanning',
          //   path: 'route-planning',
          //   component: () => import('#/views/closed-management/hazardous-transport/RoutePlanning.vue'),
          //   meta: {
          //     icon: Route,
          //     title: $t('page.closedManagement.routePlanning'),
          //   },
          // },
        ],
      },

      {
        name: 'PersonnelDistribution',
        path: 'personnel-distribution',
        meta: {
          icon: Users,
          title: $t('page.closedManagement.personnelDistribution'),
          authority: ['AC100000', 'AC100001'],
        },
        children: [
          {
            name: 'RealTimeLocation',
            path: 'real-time-location',
            component: () =>
              import(
                '#/views/closed-management/personnel-distribution/RealTimeLocation.vue'
              ),
            meta: {
              // icon: MapPin,
              title: $t('page.closedManagement.realTimeLocation'),
              username: '实时位置',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'AbnormalDistrialarm',
            path: 'abnormal-distrialarm',
            component: () =>
              import(
                '#/views/closed-management/personnel-distribution/AbnormalDistrialarm.vue'
              ),
            meta: {
              // icon: MapPin,
              title: $t('page.closedManagement.abnormalDistrialarm'),
              username: '人员异常分布报警',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'AbnormalPersonnelAnalysis',
            path: 'abnormal-analysis',
            component: () =>
              import(
                '#/views/closed-management/personnel-distribution/AbnormalPersonnelAnalysis.vue'
              ),
            meta: {
              // icon: UserX,
              title: $t('page.closedManagement.abnormalPersonnelAnalysis'),
              username: '异常人员统计分析',
              authority: ['AC100000', 'AC100001'],
            },
          },

          // {
          //   name: 'Visualization',
          //   path: 'visualization',
          //   component: () => import('#/views/closed-management/personnel-distribution/Visualization.vue'),
          //   meta: {
          //     icon: Eye,
          //     title: $t('page.closedManagement.visualization'),
          //   },
          // },
        ],
      },
      {
        name: 'HazardousParking',
        path: 'hazardous-parking',
        meta: {
          icon: Warehouse,
          title: $t('page.closedManagement.hazardousParking'),
          authority: ['AC100000', 'AC100001', 'AC100010', 'AC999999'],
        },
        children: [
          {
            name: 'ParkingInfo',
            path: 'parking-info',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/ParkingInfo.vue'
              ),
            meta: {
              // icon: ParkingCircle,
              title: $t('page.closedManagement.parkingInfo'),
              username: '停车场信息',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'AdmissionListSettings',
            path: 'admission-list',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/AdmissionListSettings.vue'
              ),
            meta: {
              // icon: ClipboardList,
              title: $t('page.closedManagement.admissionListSettings'),
              username: '准入名单设置',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'ParkingReservationApplication',
            path: 'reservation-application',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/ParkingReservationApplication.vue'
              ),
            meta: {
              // icon: CalendarCheck,
              title: $t('page.closedManagement.parkingReservationApplication'),
              username: '预约申请',
              authority: ['AC100000', 'AC100001', 'AC999999'],
            },
          },
          {
            name: 'ParkingReservationReview',
            path: 'reservation-review',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/ParkingReservationReview.vue'
              ),
            meta: {
              // icon: ClipboardCheck,
              title: $t('page.closedManagement.parkingReservationReview'),
              username: '预约审核',
              authority: ['AC100000', 'AC100001', 'AC100010'],
            },
          },
          {
            name: 'VehicleManagement',
            path: 'vehicle-management',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/VehicleManagement.vue'
              ),
            meta: {
              // icon: ClipboardCheck,
              title: $t('page.closedManagement.vehicleManagement'),
              username: '车辆进出管理',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'ParkingZoneControl',
            path: 'zone-control',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/ParkingZoneControl.vue'
              ),
            meta: {
              //  icon: Map,
              title: $t('page.closedManagement.parkingZoneControl'),
              username: '分区管控',
              authority: ['AC100000', 'AC100001'],
            },
          },
          {
            name: 'ParkingManagements',
            path: 'Parking-managements',

            meta: {
              // icon: Map,
              title: $t('page.closedManagement.parkingManagement'),
              username: '车位管理',
              authority: ['AC100000', 'AC100001'],
            },
            children: [
              {
                name: 'ParkingManagement',
                path: 'Parking-management',
                component: () =>
                  import(
                    '#/views/closed-management/hazardous-parking/ParkingManagement.vue'
                  ),
                meta: {
                  // icon: Route,
                  title: $t('page.closedManagement.parkingManagement'),
                  username: '车位管理',
                  authority: ['AC100000', 'AC100001'],
                },
              },
              {
                name: 'ParkingSpaceusage',
                path: 'Parking-spaceusage',
                component: () =>
                  import(
                    '#/views/closed-management/hazardous-parking/ParkingSpaceusage.vue'
                  ),
                meta: {
                  // icon: Route,
                  title: $t('page.closedManagement.parkingSpaceusage'),
                  username: '车位使用记录',
                  authority: ['AC100000', 'AC100001'],
                },
              },
            ],
          },
          {
            name: 'ParkingDispatchGuidance',
            path: 'dispatch-guidance',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/ParkingDispatchGuidance.vue'
              ),
            meta: {
              // icon: Route,
              title: $t('page.closedManagement.parkingDispatchGuidance'),
              username: '调度引导',
              authority: ['AC100000', 'AC100001'],
            },
          },

          // {
          //   name: 'SafetyRiskMonitoring',
          //   path: 'safety-risk',
          //   component: () => import('#/views/closed-management/hazardous-parking/SafetyRiskMonitoring.vue'),
          //   meta: {
          //     icon: AlertOctagon,
          //     title: $t('page.closedManagement.safetyRiskMonitoring'),
          //   },
          // },
          {
            name: 'StatisticalAnalysis',
            path: 'statistical-analysis',
            component: () =>
              import(
                '#/views/closed-management/hazardous-parking/StatisticalAnalysis.vue'
              ),
            meta: {
              // icon: LineChart,
              title: $t('page.closedManagement.statisticalAnalysis'),
              username: '统计分析',
              authority: ['AC100000', 'AC100001'],
            },
          },
        ],
      },
    ].filter((route) => {
      if (!route.name) {
        console.error('Route missing name:', route);
        return false;
      }
      return true;
    }),
  },
];

// 添加一个检查函数
function checkRoutes(routes: RouteRecordRaw[]) {
  routes.forEach((route) => {
    if (!route.name) {
      console.error('Route missing name:', route);
    }
    if (route.children) {
      checkRoutes(route.children);
    }
  });
}

checkRoutes(routes);

export default routes;
